<?php if($action == 'edit'):?>
    <form action="<?php echo $this->baseurl("/admin/account/{$action}") ?>" method="post">
    <input type="hidden" name="data[Admin][id]" value="<?php echo $user_data['id'];?>" />
    <?php echo $this->callElement("default/tools/tool_bar",array("buttons"=>array(array("type"=>"back"),array('type'=>'save')),"custom_html"=> App::Helper("Html")->ButtonTag("View","View Account",array("onclick"=>"document.location='" . $this->baseurl("/admin/account/view") . "';")) ,"title" => "{$user_data['f_name']} {$user_data['l_name']}")); ?>
    
    <?php if(isset($message)):?>
    <?php echo $this->callElement('default/tools/message', array('caption' =>'Message','type' => 'success', 'message' => $message)); ?>
    <?php elseif(isset($error)):?>
    <?php echo $this->callElement('default/tools/message', array('caption' =>'Message','type' => 'error', 'message' => $error)); ?>
    <?php endif;?>
    
    <table width="100%">
    <tr>
        <td>
            <div class="app_box">
                <h3 class="app_box_title "><span class="box-button"> </span><input type="checkbox" name="data[Admin][UpdateProfile]" id="updateprofile" checked="checked" /> <label for="updateprofile" class="pointer">Update Personal Information</label></h3>
                <div class="box-body">
                    <?php
                        App::Module('DataGrid') ->setDisplay('FormListing')
                                                ->addRow("First Name",App::Helper("Html")->inputTag("data[Admin][f_name]",$user_data['f_name'],Array("class"=>"app_input prof_input")))
                                                ->addRow("Last Name",App::Helper("Html")->inputTag("data[Admin][l_name]",$user_data['l_name'],Array("class"=>"app_input prof_input")))
                                                ->addRow("Email",App::Helper("Html")->inputTag("data[Admin][email]",$user_data['email'],Array("class"=>"app_input prof_input")))
                                                ->addRow("Description",App::Helper("Html")->textareaTag("data[Admin][description]",$user_data['description'],Array("class"=>"app_input prof_input")))
                                                ->Render(); 
                    ?>
                </div>
            </div>    
        </td>
        <td>
            <div class="app_box">
                <h3 class="app_box_title "><span class="box-button"> </span><input type="checkbox" name="AdminPassword[Update]" id="updatepassword" <?php if(isset($this->post['AdminPassword']['Update'])):?> checked="checked" <?php endif;?> /> <label for="updatepassword" class="pointer">Update Login Password</label></h3>
                <div class="box-body">            
                    <?php
                        $this->post['AdminPassword'] = isset($this->post['AdminPassword']) ? $this->post['AdminPassword'] : Array();
                        App::Module('DataGrid') ->clear()
                                                ->setDisplay('FormListing')
                                                ->addRow("Old&nbsp;Password",App::Helper("Html")->passwordTag("AdminPassword[old]",App::Helper('Html')->selectDefaultValue($this->post['AdminPassword'],'old',""),Array("class"=>"app_input pass_input")))
                                                ->addRow("New&nbsp;Password",App::Helper("Html")->passwordTag("AdminPassword[new]",App::Helper('Html')->selectDefaultValue($this->post['AdminPassword'],'new',""),Array("class"=>"app_input pass_input")))
                                                ->addRow("Confirm&nbsp;Password",App::Helper("Html")->passwordTag("AdminPassword[confirm]",App::Helper('Html')->selectDefaultValue($this->post['AdminPassword'],'confirm',""),Array("class"=>"app_input pass_input")))
                                                ->addRow("Purpose",App::Helper("Html")->textareaTag("AdminPassword[porpose]",App::Helper('Html')->selectDefaultValue($this->post['AdminPassword'],'porpose',""),Array("class"=>"app_input pass_input")))
                                                ->Render();
                   ?>
                </div>
            </div>
        </td>
    </tr>
    </table>
    <?php echo $this->callElement("default/tools/tool_bar",array("buttons"=>array(array("type"=>"back"),array('type'=>'save')),"position" => 'bottom')); ?>
    </form>
    <script type="text/javascript">
        window.addEvent('domready', function(){
            <?php if(isset($this->post['AdminPassword']['Update'])):?> 
                $$('.pass_input').set('disabled',false);
            <?php else:?>
                $$('.pass_input').set('disabled',true);
            <?php endif;?>
            
            $('updatepassword').addEvent('click',function(){
                $$('.pass_input').set('disabled',(!this.checked));
            });
            
            $('updateprofile').addEvent('click',function(){ 
                $$('.prof_input').set('disabled',(!this.checked));
            });
        });
    </script>
<?php else:?>
    <?php echo $this->callElement("default/tools/tool_bar",array("buttons"=>array(array("type"=>"back")),"custom_html"=> App::Helper("Html")->ButtonTag("Edit","Edit Account",array("onclick"=>"document.location='" . $this->baseurl("/admin/account/edit") . "';")) ,"title" => "{$user_data['f_name']} {$user_data['l_name']}")); ?>
    <?php
        App::Module('DataGrid') ->clear()
                                ->setDisplay('FormListing')
                                ->addRow("First Name",$user_data['f_name'])
                                ->addRow("Last Name",$user_data['l_name'])
                                ->addRow("Email",$user_data['email'])
                                ->addRow("User Name",$user_data['username'])
                                ->addRow("Created On",App::Helper('Date')->DateFormated($user_data['createdate'], 'long'))
                                ->addRow("Last Login",App::Helper('Date')->DateFormated($user_data['lastlogin'],'long'))
                                ->addRow("Type",$user_data['type'])
                                ->addRow("Description",$user_data['description'])
                                ->Render();
    ?>    
    <?php echo $this->callElement("default/tools/tool_bar",array("buttons"=>array(array("type"=>"back")),"position" => 'bottom')); ?>
<?php endif;?>    